public class Regular_String {
    public static void main(String[] args) {
        String str = "User13UseraaaUser345";

        /* replaceAll(reg,str)：根据正则替换匹配的所有字符串 */
        System.out.println(str.replaceAll("User\\d", "--"));//--3Useraaa--45

        /* replace(reg,str)：不可使用正则 */
        System.out.println(str.replace("User\\d", "--"));//User13UseraaaUser345

        /* split(reg)：根据正则截取匹配的所有字符串 */
        String[] split = str.split("User\\d");
        for (String s : split) {
            System.out.println(s);//["", "3Useraaa", "45"]
        }

        /* matches(reg)：根据正则判断字符串是否完全匹配 */
        System.out.println(str.matches("User\\d"));//false
        System.out.println("User1".matches("User\\d"));//true
    }
}
